package com.deyinet.bdcms.entity;

import javax.persistence.*;
import java.sql.Timestamp;

/**
 * Created by Administrator on 2017/8/30 0030.
 */
@Entity
public class Devicedata {
    private Integer id;
    private byte[] metadata;
    private Timestamp createdate;
    private Device deviceByDevicesn;
    private Integer status;
    private String sn;
    private String dataString;
    private Float report;
    private Float voltage;

    @Id
    @Column(name = "id", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Basic
    @Column(name = "metadata", nullable = true, length = -1)
    public byte[] getMetadata() {
        return metadata;
    }

    public void setMetadata(byte[] metadata) {
        this.metadata = metadata;
    }

    @Basic
    @Column(name = "createdate", nullable = true)
    public Timestamp getCreatedate() {
        return createdate;
    }

    public void setCreatedate(Timestamp createdate) {
        this.createdate = createdate;
    }

    @Basic
    @Column(name = "waterline")
    public Float getReport() {
        return report;
    }

    public void setReport(Float report) {
        this.report = report;
    }

    @Basic
    @Column(name = "voltage")
    public Float getVoltage() {
        return voltage;
    }

    public void setVoltage(Float voltage) {
        this.voltage = voltage;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Devicedata that = (Devicedata) o;
        if (id != that.id) return false;
        if (metadata != null ? !metadata.equals(that.metadata) : that.metadata != null) return false;
        if (createdate != null ? !createdate.equals(that.createdate) : that.createdate != null) return false;
        return true;
    }

    @Override
    public int hashCode() {
        int result = id;
        result = 31 * result + (metadata != null ? metadata.hashCode() : 0);
        result = 31 * result + (createdate != null ? createdate.hashCode() : 0);
        return result;
    }

    @ManyToOne
    @JoinColumn(name = "sn", referencedColumnName = "sn", foreignKey = @ForeignKey(name = "devicedata_ibfk_1"))
    public Device getDeviceByDevicesn() {
        return deviceByDevicesn;
    }

    public void setDeviceByDevicesn(Device deviceByDevicesn) {
        this.deviceByDevicesn = deviceByDevicesn;
    }

    @Column(name = "sn", insertable = false, updatable = false)
    public String getSn() {
        return sn;
    }

    public void setSn(String sn) {
        this.sn = sn;
    }

    @Transient
    public String getDataString() {
        return dataString;
    }

    public void setDataString(String dataString) {
        this.dataString = dataString;
    }

    @Column(name = "status")
    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }
}
